package com.hzpd.hainan.app;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hzpd.hainan.utils.SPUtil;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by 猪猪侠 on 2017/6/30.
 */

public abstract class BaseFragment extends Fragment{

    private Unbinder unbinder;
    public Activity activity;
    protected FragmentManager fm;
    protected SPUtil spu;//
    public View root;


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = getActivity();
        fm=getChildFragmentManager();
        spu=SPUtil.getInstance();
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       root = inflater.inflate(setMyContentView(),null);

        unbinder = ButterKnife.bind(this,root);
        initView();
        initData();
        return root;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    public  abstract int setMyContentView();
    public abstract void initView();
    public abstract void initData();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
